<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body>
	<form class="layui-form" action="" lay-filter="dept-edit-form" style="margin-top: 20px;">
		<div class="layui-form-item">
			<label class="layui-form-label">上级部门：</label>
			<div class="layui-input-block">
				<input name="deptId" th:value="${sysDept.deptId}" type="hidden">
				<input id="parentId" name="parentId" th:value="${sysDept.parentId}" type="hidden">
				<input name="" lay-verify="required" autocomplete="off" class="layui-input"
					th:value="${parentDeptName}" readonly="readonly">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">部门名称：</label>
			<div class="layui-input-block">
				<input name="name" placeholder="请输入部门名称" autocomplete="off" class="layui-input"
					th:value="${sysDept.name}" lay-verify="required">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">状态：</label>
			<div class="layui-input-block">
				<input type="radio" th:field="*{sysDept.delFlag}" name="delFlag" value="1" title="正常" checked>
				<input type="radio" th:field="*{sysDept.delFlag}" name="delFlag" value="0" title="删除">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">排序号：</label>
			<div class="layui-input-block">
				<input name="orderNum" placeholder="请输入排序号" autocomplete="off" class="layui-input"
					th:value="${sysDept.orderNum}" lay-verify="number">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit="" lay-filter="dept-edit">立即提交</button>
			</div>
		</div>
	</form>
	<div th:include="include::footer"></div>
	<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
	<script>
		layui.use([ 'form', 'layedit', 'laydate' ], function() {
			var form = layui.form, layer = layui.layer, layedit = layui.layedit, laydate = layui.laydate;
			var $ = layui.jquery;

			//监听提交
			form.on('submit(dept-edit)', function(data) {
				//提交数据data.field
				$.ajax({
					cache : true,
					type : "POST",
					url : "/sys/dept/update",
					data : data.field,
					async : false,
					error : function(request) {
						layer.alert("Connection error");
					},
					success : function(r) {
						if (r.retCode == '0000') {
							parent.layer.msg("保存成功");
							parent.location.reload(); // 父页面刷新
							var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
							parent.layer.close(index);
						} else {
							layer.alert(r.retMsg)
						}
					}
				});
				return false;
			});
		});
	</script>
</body>
</html>